import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.net.ServerSocket;

public class Server {

	public static String buffer;
	public static ServerSocket listener;
	public static void main(String args[]) {
		try {
			listener = new ServerSocket(9090);
			Thread t = new Listener();
			t.start();

			BufferedReader br = null;
			br = new BufferedReader(new FileReader("appClientModule/input.txt"));
			while (true) {

				Thread.sleep(1000);

				String sCurrentLine;

				int i = 0;
				buffer = "";
				if((sCurrentLine = br.readLine()) != null) {
					buffer = sCurrentLine.trim() + ",";
					i++;
				}
				else{
					br.close();
					br = new BufferedReader(new FileReader("appClientModule/input.txt"));
				}
				while ( i < 10 && (sCurrentLine = br.readLine()) != null) {
					if (i == 9) {
						buffer += sCurrentLine.trim();
					} else
						buffer += sCurrentLine.trim() + ",";
					i++;
				}
			}
		} catch (InterruptedException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}